﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zombicide.Model;

namespace Zombicide.Data
{
    public class Database
    {
        public List<Board> Boards { get; set; }
        public List<Tile> Tiles { get; set; }
        public List<Weapon> Weapons { get; set; }
        public List<Zombie> Zombies { get; set; }
        public List<Hero> Heroes { get; set; }

        public Database()
        {
            InitTiles();
            InitBoard();
            InitWeapons();
            InitHeroes();
            InitZombies();
        }

        public void InitBoard()
        {
            Boards = new List<Board>();
            Board newBoard = new Board { Name = "FirstStreet"};
            newBoard.Tiles = Tiles.Where(t => t.Name == "A Recto").ToList();
            Boards.Add(newBoard);
        }

        public void InitTiles()
        {
            Tiles = new List<Tile>();
            Tile newTile = new Tile { Name = "A Recto", ImageName = "Tiles/Main/Dalle A Recto.JPG" };
            newTile.Squares = new List<Square> { 
                new Square { X = 0, Y = 0, IsEntry = true },
                new Square { X = 1, Y = 0, IsEntry = true },
                new Square { X = 2, Y = 0 },
                new Square { X = 3, Y = 0 },
                new Square { X = 0, Y = 1, IsEntry = true },
                new Square { X = 1, Y = 1, IsEntry = true, IsSalvageable = true },
                new Square { X = 2, Y = 1 },
                new Square { X = 3, Y = 1 }
            };
            Tiles.Add(newTile);
        }

        public void InitWeapons()
        {
            Weapons = new List<Weapon>
            {
                new Weapon{Name = "44. Magnum",Type = WeaponType.FirearmSemiAuto,AmmoTypeUsed = AmmoType.bullet11mm,Accuracy = 3,Damage = 3,Fiability = 5,PA = 1,Weight= 2000,Sound = 5},
                new Weapon{Name = "Desert Eagle",Type = WeaponType.FirearmAuto,AmmoTypeUsed = AmmoType.bullet11mm,Accuracy = 4,Damage = 3,Fiability = 4,PA = 1,Weight= 2400,Sound = 4},
                
                new Weapon{Name = "357 Magnum",Type = WeaponType.FirearmSemiAuto,AmmoTypeUsed = AmmoType.bullet9mm,Accuracy = 2,Damage = 2,Fiability = 5,PA = 1,Weight= 1200,Sound = 4},
                new Weapon{Name = "Glock",Type = WeaponType.FirearmAuto,AmmoTypeUsed = AmmoType.bullet9mm,Accuracy = 3,Damage = 1,Fiability = 3,PA = 1,Weight= 750,Sound = 3},
                
                new Weapon{Name = "Shotgun",Type = WeaponType.FirearmSemiAuto,AmmoTypeUsed = AmmoType.bullet12mm,Accuracy = 2,Damage = 2,Fiability = 3,PA = 1,Weight= 3400,Sound = 5},
                new Weapon{Name = "SPAS 12",Type = WeaponType.FirearmSemiAuto,AmmoTypeUsed = AmmoType.bullet12mm,Accuracy = 2,Damage = 2,Fiability = 3,PA = 1,Weight= 4400,Sound = 4},
                
                new Weapon{Name = "MP5",Type = WeaponType.FirearmAuto,AmmoTypeUsed = AmmoType.bullet9mm,Accuracy = 3,Damage = 1,Fiability = 4,PA = 1,Weight= 2800,Sound = 3},//Munition à changer ?
                new Weapon{Name = "M16",Type = WeaponType.FirearmAuto,AmmoTypeUsed = AmmoType.bullet762mm,Accuracy = 3,Damage = 2,Fiability = 4,PA = 1,Weight= 4400,Sound = 4},//Munition à changer ?
                
                new Weapon{Name = "Winchester",Type = WeaponType.FirearmAuto,AmmoTypeUsed = AmmoType.bullet762mm,Accuracy = 4,Damage = 1,Fiability = 3,PA = 1,Weight= 3200,Sound = 4},
                new Weapon{Name = "Dragounov",Type = WeaponType.FirearmAuto,AmmoTypeUsed = AmmoType.bullet762mm,Accuracy = 4,Damage = 2,Fiability = 3,PA = 1,Weight= 4200,Sound = 4},
                new Weapon{Name = "FF-FR2",Type = WeaponType.FirearmAuto,AmmoTypeUsed = AmmoType.bullet762mm,Accuracy = 5,Damage = 3,Fiability = 4,PA = 1,Weight= 5200,Sound = 5},

                new Weapon{Name = "Knife",Type= WeaponType.Cutting,AmmoTypeUsed = AmmoType.None,Accuracy = 4,Damage = 1,Fiability = 3,PA = 1,Weight= 200,Sound = 0},
                new Weapon{Name = "Sword",Type= WeaponType.Cutting,AmmoTypeUsed = AmmoType.None,Accuracy = 4,Damage = 2,Fiability = 4,PA = 1,Weight= 1200,Sound = 0},
                new Weapon{Name = "Katana",Type= WeaponType.Cutting,AmmoTypeUsed = AmmoType.None,Accuracy = 5,Damage = 3,Fiability = 5,PA = 1,Weight= 800,Sound = 0},
                new Weapon{Name = "Chain Saw",Type= WeaponType.Cutting,AmmoTypeUsed = AmmoType.Gasoline,Accuracy = 4,Damage = 3,Fiability = 4,PA = 2,Weight= 8000,Sound = 4},
                
                new Weapon{Name = "Plank",Type= WeaponType.Blunt,AmmoTypeUsed = AmmoType.None,Accuracy = 4,Damage = 1,Fiability = 1,PA = 1,Weight= 2000,Sound = 1},
                new Weapon{Name = "Stick",Type= WeaponType.Blunt,AmmoTypeUsed = AmmoType.None,Accuracy = 4,Damage = 1,Fiability = 2,PA = 1,Weight= 800,Sound = 1},
                new Weapon{Name = "Pipe",Type= WeaponType.Blunt,AmmoTypeUsed = AmmoType.None,Accuracy = 4,Damage = 1,Fiability = 4,PA = 1,Weight= 800,Sound = 2},
                new Weapon{Name = "Mace",Type= WeaponType.Blunt,AmmoTypeUsed = AmmoType.None,Accuracy = 3,Damage = 2,Fiability = 3,PA = 2,Weight= 6000,Sound = 2},
            };
        }
        
        // Amelioration : baillonet (couteaux + arme à feu ? + Skotch) / silencieux / Poigné de stabilité ?
        // Planche avec clou ?

        public void InitHeroes()
        {
            Heroes = new List<Hero>
            {
                new Hero{ Name = "Emy",PA = 3,Hp = 3 },//Generation aleatoire (possibilité de rename)                
            };
        }

        public void InitZombies()
        {
            Zombies = new List<Zombie>
            {
                new Zombie{ Name = "Zombie", Hp = 2, PA = 2 },
                
            };
        }
    }
}
